package main

func queryResults(limit int, queries [][]int) []int {
	balls := make(map[int]int)
	colorCount := make(map[int]int)
	var result []int
	for _, query := range queries {
		oldColor := balls[query[0]]
		if oldColor != 0 {
			colorCount[oldColor]--
			if colorCount[oldColor] == 0 {
				delete(colorCount, oldColor)
			}
		}
		balls[query[0]] = query[1]
		colorCount[query[1]]++
		result = append(result, len(colorCount))
	}
	return result
}

func main() {
	result := queryResults(4, [][]int{
		{1, 4}, {2, 5}, {1, 3}, {3, 4},
	})
	println(result)
}
